﻿using Galoap;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using System.Collections.Generic;
using System;
using System.Transactions;

namespace Tests
{


    /// <summary>
    ///This is a test class for GameSessionTest and is intended
    ///to contain all GameSessionTest Unit Tests
    ///</summary>
    [TestClass()]
    public class GameSessionTest
    {
        private TestContext testContextInstance;

        /// <summary>
        ///Gets or sets the test context which provides
        ///information about and functionality for the current test run.
        ///</summary>
        public TestContext TestContext
        {
            get
            {
                return testContextInstance;
            }
            set
            {
                testContextInstance = value;
            }
        }

        #region Additional test attributes
        // 
        //You can use the following additional attributes as you write your tests:
        //
        //Use ClassInitialize to run code before running the first test in the class
        //[ClassInitialize()]
        //public static void MyClassInitialize(TestContext testContext)
        //{
        //}
        //
        //Use ClassCleanup to run code after all tests in a class have run
        //[ClassCleanup()]
        //public static void MyClassCleanup()
        //{
        //}
        //
        //Use TestInitialize to run code before running each test
        //[TestInitialize()]
        //public void MyTestInitialize()
        //{
        //}
        //
        //Use TestCleanup to run code after each test has run
        //[TestCleanup()]
        //public void MyTestCleanup()
        //{
        //}
        //
        #endregion


        /// <summary>
        ///A test for GetUserGameSessionsWithHighestScore
        ///</summary>
        [TestMethod()]
        public void GetUserGameSessionsWithHighestScoreTest()
        {
            User user = User.GetUserByNickname("einstein");
            List<GameSession> actual = GameSession.GetUserGameSessionsWithHighestScore(user);
            Assert.AreEqual(1000, actual[0].Score);
        }

        /// <summary>
        ///A test for GetLastGameSessionByUser
        ///</summary>
        [TestMethod()]
        public void GetLastGameSessionByUserTest()
        {
            User user = User.GetUserByNickname("einstein");
            GameSession actual = GameSession.GetLastGameSession(user);
            Assert.AreEqual(new DateTime(2010, 1, 1), actual.Date);
        }

        /// <summary>
        ///A test for GetLastGameSessionByGame
        ///</summary>
        [TestMethod()]
        public void GetLastGameSessionByGameTest()
        {
            Game game = Game.GetGame(2);
            GameSession actual = GameSession.GetLastGameSession(game);
            Assert.AreEqual(new DateTime(2010, 1, 1), actual.Date);
        }

        /// <summary>
        ///A test for GetLastGameSession
        ///</summary>
        [TestMethod()]
        public void GetLastGameSessionTest()
        {
            GameSession actual = GameSession.GetLastGameSession();
            Assert.AreEqual(new DateTime(2010, 1, 1), actual.Date);
        }

        /// <summary>
        ///A test for GetDayWithMaxGameSessions
        ///</summary>
        [TestMethod()]
        public void GetDayWithMaxGameSessionsTest()
        {
            DateTime expected = new DateTime(2010, 1, 1);
            DateTime actual = GameSession.GetDayWithMaxGameSessions();
            Assert.AreEqual(expected, actual);
        }

        /// <summary>
        ///A test for GetAllGameSessions
        ///</summary>
        [TestMethod()]
        public void GetAllGameSessionsTest()
        {
            List<GameSession> actual = GameSession.GetAllGameSessions();
            Assert.AreEqual(7, actual.Count);
        }

        /// <summary>
        ///A test for GetUserGameSessionsWithLowestScore
        ///</summary>
        [TestMethod()]
        public void GetUserGameSessionsWithLowestScoreTest()
        {
            User user = User.GetUserByNickname("einstein");
            List<GameSession> actual = GameSession.GetUserGameSessionsWithLowestScore(user);
            Assert.AreEqual(2, actual[0].Score);
        }

        /// <summary>
        ///A test for AddGameSession
        ///</summary>
        [TestMethod()]
        public void AddGameSessionTest()
        {
            /*GameSession newGameSession = new GameSession();
            newGameSession.User = User.GetUserByNickname("einstein");
            newGameSession.Game = Game.GetGame(2);
            newGameSession.AddGameSession();
            Assert.AreEqual(8, GameSession.GetAllGameSessions().Count);*/
        }
    }
}
